gnoi-shutdown: use per-thread DB connections to avoid crossed DPU reads#408
gnoi-shutdown: use per-thread DB connections to avoid crossed DPU reads#408gpunathilell wants to merge 2 commits into
Conversation
Signed-off-by: gpunathilell <gpunathilell@nvidia.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
… connection test Signed-off-by: gpunathilell <gpunathilell@nvidia.com>
6740fd9 to
c6b49a9
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
| # single non-thread-safe socket, so sharing one lets | ||
| # concurrent DPU reads cross their IP/port values. | ||
| thread_config_db = daemon_base.db_connect("CONFIG_DB") | ||
| thread_state_db = daemon_base.db_connect("STATE_DB") |
There was a problem hiding this comment.
nit (optional, non-blocking): each DPU shutdown opens two fresh redis connections here that live only for this transition. swsscommon.DBConnector has no explicit close()/disconnect(), so they're reclaimed only when
handle_and_cleanup() returns and these locals go out of scope. That's fine given how infrequently DPUs shut down(≤8 per chassis), but good to fix this issue. Otherwise the PR looks good to me
There was a problem hiding this comment.
@vvolam similar handling is done for all the other daemons in pmon (chassisd/xcvrd) etc. The disconnect is not called explicitly and handled by the garbage collection when it goes out of scope, the function only stays in scope until the shutdown happens, and then we can close it
What I did
gnoi-shutdown-daemonspawns one worker thread per DPU on shutdown, but all threads shared a single CONFIG_DB/STATE_DB redis connection created once inmain(). A redisDBConnectoris a single, non-thread-safe socket, so when multiple DPUs shut down in parallel theirhget/Tablereads interleave on the wire and replies get matched to the wrong request — producing crossed IP/port values between DPUs.This gave gnoi_client a bad target like
169.254.200.1:169.254.200.2(dpu0's IP as host, dpu1's IP in the port slot), causing:Fix
Give each per-DPU worker thread its own CONFIG_DB/STATE_DB connection so reads can never cross:
handle_and_cleanup()opens freshdb_connect("CONFIG_DB")/db_connect("STATE_DB")per thread and passes them into_handle_transition()._handle_transition()/_wait_for_gnoi_halt_in_progress()take optional per-thread connections, falling back to the shared ones for direct/unit-test callers (backward compatible).Testing
py_compileclean.169.254.200.2:50052), and fallback-to-shared preserves existing unit-test behavior.